﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary.Extension;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
public partial class TrainClassManagement_UpdateTrainClass : AdminUserBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TrainClassModule tm = new TrainClassModule();
            V_TrainClass tracl = new V_TrainClass();
            int ID = Convert.ToInt32(Request.QueryString["TCID"].ToString());
            tracl =tm.GetTrainClassModelById(ID);
            txtTrainClassName.Text = tracl.VTC_name;
            txtCount.Text = tracl.MaxUserCount.ToString();
            txtNum.Text = tracl.VTC_Number;
            dlschool.SelectedValue = tracl.SchoolID.ToString();
            txtTrainMessage.Text = tracl.VTC_desc;
          
            chkIsEnable.Checked = tracl.IsPublish==1?true:false;
            TeacherModule ta = new TeacherModule();
            List<V_School> vs = new List<V_School>();
            vs = ta.GetSchool();
            dlschool.DataSource = vs;
            dlschool.DataBind();
            dlschool.SelectedValue = this.SchoolID.ToString();
            dlschool.Enabled = false;
        }
    }
    protected void btnReg_Click(object sender, EventArgs e)
    {
        TrainClassModule tm = new TrainClassModule();
        V_TrainClass tracl = new V_TrainClass();
        tracl.ID = Convert.ToInt32(Request.QueryString["TCID"].ToString());
        tracl.SchoolID = Convert.ToInt32(dlschool.SelectedValue);
        tracl.update_time =DateTime.Now;
        tracl.VTC_desc = txtTrainMessage.Text.ToString();
        tracl.VTC_name = txtTrainClassName.Text.Trim();
        tracl.VTC_Number = this.txtNum.Text;
        tracl.MaxUserCount = Convert.ToInt32(txtCount.Text);

        tracl.IsPublish = this.chkIsEnable.Checked ? 1 : 0;
        int result = tm.UpdateTrainClass(tracl);
        if (result == 1)
        {
            PageHelper.AlterMsgAndRedirect("修改培训班成功！", "ViewTrainingClassList.aspx");
            //Label1.Text = "修改培训班成功！"; 
        }
        else
        { Label1.Text = "修改培训班失败！"; }


    }

    protected void txtCount_TextChanged(object sender, EventArgs e)
    {
        if (!StringUtils.IsNumeric(txtCount.Text))
        {
            ltrChk.Visible = true;
            btnReg.Enabled = false;
        }
        else
        {
            btnReg.Enabled = true;
        }
    }
   
}

